<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String appid = request.getParameter("selectAppId");
%>
<!DOCTYPE html>
<html>
<head>
    <title>服务机构管理</title>
    <%@ include file="../common/meta.jsp" %>
    <%@ include file="../common/common-body.jsp" %>
    <script src="${ctx}/js/common/common-body.js?t=${now}"></script>
    <link href="${ctx}/css/common-body.css?t=${now}" rel="stylesheet">
    <link href="${ctx}/css/page/common-list.css?t=${now}" rel="stylesheet">
    <link href="${ctx}/css/page/common-search.css?t=${now}" rel="stylesheet">
    <style>
        .modal-body-height > .form-group > div{
            padding-top: 7px;
        }
    </style>
    <script>
        var appid = '<%=appid%>';
        var DataStatus = ${DataStatus};
        var PushlishStatus = ${PushlishStatus};
        var OperateType = ${OperateType};
        var resultTypeMap = ${resultTypeMap};
        <%--var searchobj= ${searchInfo};--%>
        var searchInfo = ${searchInfo};
        var showQrCode = '${JTYS}';
    </script>
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
        <div class="tabs-container">
            <ul class="nav nav-tabs">
                <li class="active">
                    <a href="${ctx}/bizApp/orgPage?isTeamExist=${not empty searchInfo ? searchInfo.isTeamExist : 1}&isDocExist=${not empty searchInfo ? searchInfo.isDocExist : 1}" aria-expanded="true">服务机构</a>
                </li>
                <c:if test="${not empty searchInfo && searchInfo.isTeamExist == 1}">
                    <li class="">
                        <a href="${ctx}/bizApp/teamPage?isOrgExist=${not empty searchInfo ? searchInfo.isOrgExist : 1}&isDocExist=${not empty searchInfo ? searchInfo.isDocExist : 1}" aria-expanded="true">机构团队</a>
                    </li>
                </c:if>
                <c:if test="${not empty searchInfo && searchInfo.isDocExist == 1}">
                    <li class="">
                        <a href="${ctx}/bizApp/docPage?isOrgExist=${not empty searchInfo ? searchInfo.isOrgExist : 1}&isTeamExist=${not empty searchInfo ? searchInfo.isTeamExist : 1}" aria-expanded="true">机构专家</a>
                    </li>
                </c:if>
            </ul>
            <div class="row">
                <div class="col-sm-12">
                    <div class="ibox float-e-margins">
                        <div class="ibox-title">
                            <h5><i class="fa fa-search"></i> 筛选查询</h5>
                        </div>
                        <div class="ibox-content ibox-content-search">
                            <form class="form-horizontal m-t" id="searchForm" novalidate="novalidate">
                                <div class="form-group">
                                    <label class="col-sm-1 control-label">查询机构：</label>
                                    <div class="col-sm-5">
                                        <input type="text" id="orgName" name="orgName"
                                               value="${not empty searchInfo.orgName ?searchInfo.orgName :""}"
                                               onkeydown="if(event.keyCode==13){doRefresh();return false;}"
                                               class="form-control" placeholder="输入机构名称" maxlength="30">
                                    </div>
                                    <label class="col-sm-1 control-label">业务类型：</label>
                                    <div class="col-sm-2">
                                        <select class="form-control" name="bizCode" onchange="doRefresh()">
                                            <option value="">--请选择--</option>
                                            <c:forEach items="${bizList}" var="item">
                                                <option value="${item.bizCode}"
                                                    ${not empty searchInfo.bizCode && searchInfo.bizCode == item.bizCode ? 'selected' : '' }
                                                >${item.bizName}</option>
                                            </c:forEach>
                                        </select>
                                    </div>
                                    <div class="ibox-tools ibox-tools-search">
                                        <button type="button" class="btn btn-primary btn-outline" onclick="doRefresh()">
                                            查询
                                        </button>
                                        <button type="button" class="btn btn-primary btn-outline" onclick="clearFrom('searchForm')">重置</button>
                                        <button type="button" class="btn btn-primary btn-outline" onclick="openSearchTools();"><i class="fa fa-caret-down"></i></button>
                                    </div>
                                </div>
                                <div class="search-tools">
                                    <div class="form-group">
                                        <label class="col-sm-1 control-label">发布状态：</label>
                                        <div class="col-sm-2">
                                            <select class="form-control" name="status" id="status"
                                                    onchange="doRefresh()">
                                                <option value="">--请选择--</option>
                                                <c:forEach items="${PushlishStatus}" var="item">
                                                    <option value="${item.key}"
                                                        ${not empty searchInfo.status && searchInfo.status == item.key ? 'selected' : '' }
                                                    >${item.value}</option>
                                                </c:forEach>
                                            </select>
                                        </div>
                                        <label class="col-sm-1 control-label">数据状态：</label>
                                        <div class="col-sm-2">
                                            <select class="form-control" name="dataStatus" id="dataStatus" onchange="doRefresh()">
                                                <option value="">--请选择--</option>
                                                <c:forEach items="${DataStatus}" var="item">
                                                    <option value="${item.key}"
                                                        ${not empty searchInfo.dataStatus && searchInfo.dataStatus == item.key ? 'selected' : '' }
                                                    >${item.value}</option>
                                                </c:forEach>
                                            </select>
                                        </div>
                                        <label class="col-sm-1 control-label">服务商：</label>
                                        <div class="col-sm-3">
                                            <div class="input-group">
                                                <input type="text" class="hideItem" id="PisvPid" name="isvPid"
                                                       value="${not empty searchInfo.isvPid ?searchInfo.isvPid :""}"
                                                >
                                                <input type="text" id="pIsvName" name="isvName" class="form-control" maxlength="25"
                                                       value="${not empty searchInfo.isvName ?searchInfo.isvName:""}"
                                                >
                                                <div class="input-group-btn" style="width:0px!important;border-radius:0px!important">
                                                    <button type="button" class="btn btn-default dropdown-toggle mySearchBtn" data-toggle="dropdown">
                                                        <span class="caret"></span>
                                                    </button>
                                                    <ul class="dropdown-menu dropdown-menu-right" role="menu">
                                                    </ul>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-12">
                    <div class="ibox float-e-margins">
                        <div class="ibox-title">
                            <h5><i class="fa fa-table"></i> 服务机构</h5>
                            <div class="ibox-tools col-sm-offset-2">
                                <c:if test="${userType == 'super' || not empty btnMap['addAppOrg']}">
                                    <button class="btn btn-primary btn-outline" onclick="add()">新增</button>
                                </c:if>
                                <c:if test="${userType == 'super' || (not empty btnMap['editAppOrg'] && userType != 'isvcomm')}">
                                    <button class="btn btn-primary btn-outline" onclick="edit()">编辑</button>
                                </c:if>
                                <c:if test="${userType == 'super' || not empty btnMap['commitAppOrg']}">
                                    <button class="btn btn-primary btn-outline" onclick="beforePubish()">提交发布</button>
                                </c:if>
                                <c:if test="${userType == 'super' || not empty btnMap['revokeAppOrg']}">
                                    <button class="btn btn-primary btn-outline" onclick="unPublishAppwin()">撤销发布</button>
                                </c:if>
                                <c:if test="${userType == 'super' || not empty btnMap['delAppOrg']}">
                                    <button class="btn btn-primary btn-outline" onclick="validateBizApp()">删除</button>
                                </c:if>
                                <c:if test="${userType == 'super' || not empty btnMap['childAppOrg']}">
                                    <button class="btn btn-primary btn-outline" onclick="updateChildrenBiz()">服务项</button>
                                </c:if>
                                <c:if test="${userType == 'super' || not empty btnMap['exportAppOrg']}">
                                    <button class="btn btn-primary btn-outline" onclick="downaload()">导出</button>
                                </c:if>
                                <button class="btn btn-primary btn-outline" onclick="doRefresh()">刷新</button>
                            </div>
                        </div>
                        <div class="ibox-content ibox-content-table">
                            <table
                                   id="dataTable"  data-height="300"
                                   data-toggle="table"
                                   data-url="${ctx}/bizApp/getGridBizAppData?t=${now}"
                                   <%--data-height="400px"--%>
                                   data-pagination="true"
                                   data-side-pagination="server"
                                   data-striped="true"
                                   data-response-handler="handleServerResult"
                                   data-query-params-type=""
                                   data-query-params="getParams"
                                   data-cache="false"
                                   data-page-number="${not empty searchInfo.pageNo ? searchInfo.pageNo : 1}"
                                   data-page-size="${defaultPageSize}"
                                   data-page-list="${pageList}">
                                <thead>
                                <tr>
                                    <%--<th data-field="checkBx" data-checkbox="true" data-width="20px"  ></th>--%>
                                    <th data-field="status" data-width="100px" data-align="center"
                                        data-formatter="publishDataStatus"
                                    >发布状态</th>
                                    <th data-field="dataStatus" data-width="100px" data-align="center"
                                        data-formatter="dataStatus"
                                    >数据状态</th>

                                    <th data-field="id" data-visible="false">主键id</th>
                                    <th data-field="bizName" data-width="100px" data-align="center" data-formatter="onceCheck"  >业务类型</th>
                                    <th data-field="orgName" data-width="200px" data-align="center">机构名称</th>
                                    <th data-field="isvName" data-width="150px" data-align="center" >服务商</th>
                                    <th data-field="sortNum" data-width="80px" data-align="center" >排序</th>
                                    <th data-field="creator" data-width="100px" data-align="center"  data-formatter="formatterCreator">创建人</th>
                                    <th data-field="operator" data-width="100px" data-align="center" data-formatter="formatterOperator">编辑人</th>
                                </tr>
                                </thead>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-12">
                    <div class="ibox float-e-margins">
                        <div class="ibox-title">
                            <h5><i class="fa fa-table"></i> 操作记录</h5>
                        </div>
                        <div class="ibox-content">
                            <table class='table table-striped table-hover'
                                   id="dataLogTable"  data-height="300"
                                   data-toggle="table"
                                   <%--data-height="400px"--%>
                                   <%--data-url="${ctx}/bizApp/getGridIsvData?t=${now}"--%>
                                   data-pagination="true"
                                   data-side-pagination="server"
                                   data-striped="true"
                                   data-response-handler="handleServerResult"
                                   data-query-params-type=""
                                   data-query-params="getLogParams"
                                   data-page-size="${defaultPageSize}"
                                   data-page-list="${pageList}">
                                <thead>
                                <tr>
                                    <th data-field="operateType" data-align="center" data-formatter="OperateTypeFormatter" >变更类型</th>
                                    <th data-field="gmtPublish" data-align="center" >提交时间</th>
                                    <th data-field="operatorCommit" data-align="center" >提交人</th>
                                    <th data-field="remark" data-align="center">说明</th>
                                    <th data-field="gmtCreate" data-align="center" data-formatter="GmtCreateFormatter">审核时间</th>
                                    <th data-field="operator" data-align="center">审核人</th>
                                    <th data-field="result" data-align="center"  data-formatter="checkTypeFormatter">审核结果</th>
                                </tr>
                                </thead>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-12">
                    <div class="text-center">${companyName}</div>
                </div>
            </div>
        </div>
</div>
<div id="addBizApp" class="modal" tabindex="-1" role="dialog" data-backdrop="static" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content animated bounceInRight">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 id="" style="font-weight: normal;">新增服务机构</h4>
            </div>
            <div class="modal-body modal-body-height">
                <div class="row">
                    <div class="col-sm-3 text-right"><span style="color: red;">*</span>服务商：</div>
                    <div class="col-sm-9">
                        <div class="input-group">
                            <input type="text" id="SisvPid" name="isvPid" class="hideItem">
                            <input type="text" id="isvName" name="isvName" class="form-control" minlength="1" required
                                   value="${not empty user ? user.isvName : ''}">
                            <div class="input-group-btn" style="width:0px!important;border-radius:0px!important">
                                <button type="button" class="btn btn-default dropdown-toggle mySearchBtn"
                                        data-toggle="dropdown">
                                    <span class="caret"></span>
                                </button>
                                <ul class="dropdown-menu dropdown-menu-right" role="menu">
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-3 text-right"><span style="color: red;">*</span>业务类型：</div>
                    <div class="col-sm-9">
                        <select  class="form-control" id="bizCode" name="bizCode" onchange="changeBiz()">
                            <%--<option value="">--请选择--</option>--%>
                        </select>
                    </div>
                </div>
                <div style="border: 1px solid #e4eaec;-webkit-box-shadow:0px 3px 3px #c8c8c8 ;
-moz-box-shadow:0px 3px 3px #c8c8c8 ;
box-shadow:0px 3px 3px #c8c8c8 ;">
                    <h4><i class="fa fa-table"></i> 机构列表</h4>
                    <div class="row">
                        <form action="" id="winfom">
                            <div class="col-sm-3 text-right">查询机构：</div>
                            <div class="col-sm-9">
                                <div class="input-group">
                                    <input type="text"
                                           onkeydown="if(event.keyCode==13){doWinRefresh();return false;}"
                                           class="form-control" id="winOrgName" name="orgName" placeholder="输入机构名称" ><span class="input-group-btn"><button type="button" onclick="doWinRefresh()" class="btn btn-white">查询</button></span>
                                </div>
                            </div>
                        </form>
                    </div>
                    <table class='table table-striped table-hover'
                           id="WinTable"
                           data-toggle="table"
                           <%--data-url="${ctx}/bizApp/getGridOrgData?t=${now}"--%>
                           data-pagination="true"
                           data-side-pagination="server"
                           data-striped="true"
                           data-response-handler="handleServerResult"
                           data-query-params-type=""
                           data-query-params="getWinParams"
                           data-page-size="${defaultPageSize}"
                           data-page-list="${pageList}">
                        <thead>
                        <tr>
                            <th data-field="checkBx" data-checkbox="true" data-width="20px" ></th>
                            <th data-field="orgName" data-align="center" data-width="90px">机构名称</th>
                        </tr>
                        </thead>
                    </table>
                </div>
            </div>
            <div class="modal-footer" style="text-align: center;">
                <button class="btn btn-primary" onclick="doSaveApp()">保存</button>
                <button class="btn btn-white" onclick="$('#addBizApp').modal('hide')" >取消</button>
            </div>
        </div>
    </div>
</div>

<div id="editBizApp" class="modal" tabindex="-1" role="dialog" data-backdrop="static" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content animated bounceInRight">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 id="_modelTitle" style="font-weight: normal;">编辑服务机构</h4>
            </div>
            <div class="modal-body modal-body-height" >
                <h4><i class="fa fa-table"></i> 基本信息</h4>
                <hr>
                <form class="form-horizontal m-t" id="editBizAppFrom">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">业务类型：</label>
                        <div class="col-sm-8 control-label-div">
                            {{editBizApp.bizName}}
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><span style="color: red">*</span>服务商：</label>
                        <div class="col-sm-8 control-label-div">
                            {{editBizApp.isvName}}
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">机构名称：</label>
                        <div class="col-sm-8 control-label-div">
                            {{editBizApp.orgName}}
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">机构排序：</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" name="sortNum" maxlength="10" v-model="editBizApp.sortNum"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">备注：</label>
                        <div class="col-sm-10">
                            <textarea name="remark" cols="30" rows="10" class="form-control"  v-model="editBizApp.remark"></textarea>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer" style="text-align: center;">
                <button class="btn btn-primary" onclick="doEditBiz()">保存</button>
                <button class="btn btn-white" onclick="$('#editBizApp').modal('hide')">取消</button>
            </div>
        </div>
    </div>
</div>


<div id="publishApp" class="modal" tabindex="-1" role="dialog" data-backdrop="static" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content animated bounceInRight">
            <div class="modal-header text-center">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4>扫码验证</h4>
            </div>
            <div class="modal-body modal-body-height">
                <div class="row">
                    <div class="col-sm-12 text-center"><image class="login-scancode" id="scanCode" style="height: auto;width: 250px" onclick="chageQRCode();"/></div>
                    <div class="col-sm-12 text-center">提示：验证发布内容准确性，上线更放心</div>
                    <div class="col-sm-12 text-center">二维码有效期为<span id="_validNum"></span>秒</div>
                </div>
            </div>
            <div class="modal-footer" style="text-align: center;">
                <button class="btn btn-primary" id="upPublish" onclick="doPublishApp()" data-loading-text="提交中...">提交发布</button>
                <button class="btn btn-white" onclick="$('#publishApp').modal('hide')">取消</button>
            </div>
        </div>
    </div>
</div>


<div id="unPublishAppWin" class="modal" tabindex="-1" role="dialog" data-backdrop="static" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content animated bounceInRight">
            <div class="modal-header text-center">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
              <h4 >撤销发布</h4>
            </div>
            <div class="modal-body modal-body-height" >
                <div class="row">
                    <div class="col-sm-1 text-right error"></div>
                    <div class="col-sm-11 text-left"><span style="color: red">*</span>请输入撤销发布原因</div>
                </div>
                <c:forEach items="${appOperReason}" var="item">
                    <div class="row">
                        <div class="col-sm-1 text-right"></div>
                        <div class="col-sm-11 text-left"><label ><input type="checkbox" name="error_text" value="${item.dictName}">${item.dictName}</label></div>
                    </div>
                </c:forEach>
              <div class="row">
                    <div class="col-sm-1 text-right"></div>
                    <div class="col-sm-11 text-left">
                        <textarea id="error_textarea" name="error_textarea" cols="30" rows="10" class="form-control"></textarea>
                    </div>
                </div>
            </div>
            <div class="modal-footer" style="text-align: center;">
                <button class="btn btn-primary" onclick="doUnPublishApp()">撤销发布</button>
                <button class="btn btn-white" onclick="$('#unPublishAppWin').modal('hide')">取消</button>
            </div>
        </div>
    </div>
</div>


<div id="delAppWin" class="modal" tabindex="-1" role="dialog" data-backdrop="static" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content animated bounceInRight">
            <div class="modal-header text-center">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 >删除</h4>
            </div>
            <div class="modal-body modal-body-height" >
                <div class="row">
                    <div class="col-sm-1 text-right error"></div>
                    <div class="col-sm-11 text-left"><span style="color: red">*</span>请输入删除原因</div>
                </div>
                <c:forEach items="${appOperReason}" var="item">
                    <div class="row">
                        <div class="col-sm-1 text-right"></div>
                        <div class="col-sm-11 text-left"><label ><input type="checkbox" name="del_text" value="${item.dictName}">${item.dictName}</label></div>
                    </div>
                </c:forEach>
                <div class="row">
                    <div class="col-sm-1 text-right"></div>
                    <div class="col-sm-11 text-left">
                        <textarea id="del_textarea" name="del_textarea" cols="30" rows="10" class="form-control"></textarea>
                    </div>
                </div>
            </div>
            <div class="modal-footer" style="text-align: center;">
                <button class="btn btn-primary" onclick="dodelApp()">删除</button>
                <button class="btn btn-white" onclick="$('#delAppWin').modal('hide')">取消</button>
            </div>
        </div>
    </div>
</div>

<%@ include file="../common/common-body.jsp" %>
<script src="${ctx}/js/app/bizAppMgr.js?t=${now}"></script>
</body>
</html>
